<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/template.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core">


    <ui:define name="title">
        <h:outputText value="#{bundle.ListFastaTitle}"></h:outputText>
    </ui:define>
    <ui:define name="body">
        <h:form id="form" styleClass="form list">
            <p:fieldset legend="Fasta Control" >
                <c:if test="#{userController.allowedGroups('2') or userController.myselftEditing}">
                    <p:commandButton icon="ui-icon-plus" ajax="false" action="#{fastaController.prepareCreate}" value="New Fasta" />
                    <p:commandButton icon="ui-icon-plus" ajax="false" action="#{fastaController.preparImport()}" value="Import Fasta" />
                </c:if>
                <p:separator/>
                <p:dataTable id="fastaects"
                             styleClass="data"
                             var="fasta"
                             rowKey="#{fasta}"
                             value="#{fastaController.items}"
                             selection="#{fastaController.current }"
                             selectionMode="single"
                             rows="8"
                             paginator="#{fastaController.items.size() gt 8}"
                             >
                    <f:facet name="header">
                        <h:outputText value="Fastas"></h:outputText>
                    </f:facet>
                    <p:column sortBy="#{fasta.defline}" filterBy="#{fasta.defline}" filterMatchMode="contains">
                        <f:facet name="header">
                            <h:outputText value="Fasta Def"/>
                        </f:facet>
                        <h:outputText value="#{fasta.defline}"/>
                    </p:column>
                    <p:column sortBy="#{fasta.project.prjName}" filterBy="#{fasta.project.prjName}">
                        <f:facet name="header">
                            <h:outputText value="Belongs to"/>
                        </f:facet>
                        <h:outputText value="#{fasta.project.prjName}"/>
                    </p:column>
                    <p:column sortBy="#{fasta.allSequence.length()}" filterBy="#{fasta.allSequence.length()}">
                        <f:facet name="header">
                            <h:outputText value="Seq Size"/>
                        </f:facet>
                        <h:outputText value="#{fasta.allSequence.length()}"/>
                    </p:column>
                    <p:column sortBy="#{fasta.creationDate}" filterBy="#{fasta.creationDate}">
                        <f:facet name="header">
                            <h:outputText value="Created in"/>
                        </f:facet>
                        <h:outputText value="#{fasta.creationDate}"/>
                    </p:column>
                    <f:facet name="footer">
                        <h:outputText id="rowCount"
                                      value="Total number of records: #{fastaController.items.size()}" />
                        <br/>
                        <p:commandButton ajax="false" action="#{fastaController.prepareCreate}" value="New" icon="ui-icon-plus" rendered="#{empty fastaController.items}"/>
                    </f:facet>
                </p:dataTable>
                <c:if test="#{userController.allowedGroups('2')}">
                    <p:contextMenu for="fastaects" >
                        <p:menuitem value="Edit" icon="ui-icon-pencil"   action="#{fastaController.prepareEdit}" />
                        <p:menuitem value="Delete" icon="ui-icon-close" actionListener="#{fastaController.destroy}" update=":form:"/>
                        <p:menuitem value="View" icon="ui-icon-search" action="#{fastaController.prepareView}" />
                        <p:menuitem value="New" icon="ui-icon-plus" action="#{fastaController.prepareCreate}" />
                    </p:contextMenu>
                </c:if>
            </p:fieldset>
        </h:form>
    </ui:define>
</ui:composition>


